<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="deom" id="nav" index="1"></div>
    <script>
        //1.获取属性值 
        var div = document.querySelector('div');
        console.log(div.id);
        console.log(div.className);
        console.log(div.getAttribute('index'));
        //2.设置属性值
        div.id = 'text';
        div.className = 'deoms'
        div.setAttribute('index',2);
        div.setAttribute('class','deom')
        div.setAttribute('id','nav')
        //3.移除属性
        div.removeAttribute('index');
    </script>
</body>

</html>